//********************************************************************************************************************//
//ORGANIZATION:
//AUTHOR: bpeng(bogers.peng@gmail.com)
//SUMMARY:
//********************************************************************************************************************//
#ifndef NATIVE_DOMAIN_COMPILING_SQL_HEADERGATHER_H
#define NATIVE_DOMAIN_COMPILING_SQL_HEADERGATHER_H

#ifndef NATIVE_DOMAIN_COMPILING_COMMON_GATHER_H
#include "Domain/Compiling/Common/Gather.h"
#endif
#ifndef NATIVE_DOMAIN_COMPILING_COMMON_OBSERVE_H
#include "Domain/Compiling/Common/Observe.h"
#endif

namespace Native { namespace Compiling { namespace Sql
{
    const static wstring HEADER_GATHER_NAME_KEY = L"Name";
    const static wstring HEADER_GATHER_RETURN_TYPE_KEY = L"ReturnType";

    NATIVE_DECLARE_CONST_OBJECT(CVariable, C_VARIABLE);
    NATIVE_DECLARE_CONST_OBJECT(CHeader, C_HEADER);
    NATIVE_DECLARE_CONST_OBJECT(CHeaderGather, C_HEADER_GATHER);
    class NATIVE_LIBRARY_EXPORT CHeaderGather :
        public CGather,
        public ICast<CHeader>,
        public IObserve<CVariable>
    {
        NATIVE_DECLARE_OBJECT;

    protected:
        CArray<CVariable> _variables;

    public:
        CHeaderGather();
        CHeaderGather(C_HEADER_GATHER& that);
        CHeaderGather(C_HEADER_GATHER&& that);
        ~CHeaderGather();
        //{CGather
        virtual void Update() const throw();
        virtual void Clear();
        //}
        //{ICast
        virtual CHeader Cast() const throw();
        //}
        //{IObserve
        virtual void Send(const ICast<CVariable>* source) throw();
        //}
        void CollectName(C_STRING& name) throw();
        void CollectReturnType(C_STRING& return_type) throw();
    };

}}

#endif